import { DirUtil } from "./DirUtil";
import { Main } from "../Main";
import { fstat } from "fs";
import { FileIoUtil } from "./FileIOUtil";

/**
 * plistcfg生成工具
 * @author 赵占涛
 */
export class PlistCfgGenUtil {
    static gen(cb: () => void) {
        let allFile = DirUtil.getAll(Main.codePath + "Resources/res/");
        let contentStr = "return {\n";
        for (let i = 0; i < allFile.length; i++) {
            const file = allFile[i];
            if (file.endsWith(".plist") && file.indexOf("ccs/neAni") == -1) {
                contentStr += `"${file}",\n`;
            }
        }
        contentStr = contentStr.substr(0, contentStr.length - 2)
        contentStr += "\n}";
        FileIoUtil.writeFile(Main.codePath + "Resources/src/app/config/plistCfg.lua", contentStr, cb);
    }
}